﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Modules.quest.guide {
    import Modules.quest.Managers.*;
    import Modules.guide.*;
    import Modules.guide.actions.*;

    public class QuestGuideSequence extends GuideSequence {

        protected var m_quest:GameQuest;

        public function QuestGuideSequence(_arg1:Guide, _arg2:GameQuest){
            super(_arg1);
            this.m_quest = _arg2;
        }
        override public function createFromXml(_arg1:XML):Boolean{
            var name:* = null;
            var trigger:* = null;
            var xml:* = _arg1;
            if (xml == null){
                return (false);
            };
            try {
                name = xml.@name;
                trigger = xml.@trigger;
                if (name.length > 0){
                    m_name = name;
                } else {
                    return (false);
                };
            } catch(err:Error) {
                return (false);
            };
            return (true);
        }
        override public function stop(_arg1:Boolean=false):void{
            super.stop(true);
        }
        override public function update(_arg1:Number):void{
            var _local2:GuideAction;
            if (!m_active){
                return;
            };
            if (m_actionExec.getState() == null){
                _local2 = nextAction();
                if (_local2 != null){
                    GlobalEngine.log("Guide", ((("New action: " + m_name) + " / ") + _local2));
                    m_actionExec.addState(_local2);
                } else {
                    this.startNextGuide();
                    m_completed = true;
                    m_active = false;
                };
            };
            m_actionExec.update(_arg1);
        }
        protected function startNextGuide():void{
            var _local1:Object = this.m_quest.getFirstIncompleteTask();
            if (((!(_local1)) || (!(_local1.guide)))){
                return;
            };
            if (_local1.guide == m_name){
                return;
            };
            var _local2:GANotify = new GANotify();
            _local2.setGuide(m_guide, this);
            _local2.notify = _local1.guide;
            GlobalEngine.log("Guide", ((("New action: " + m_name) + " / ") + _local2));
            m_actionExec.addState(_local2);
        }

    }
}//package Modules.quest.guide 
